<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">
<style>
    .opt-btn-group{
        border-bottom: none !important;
    }
</style>
<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span>证件归还</span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">
        <div class="block-generic">
            <div class="layui-form-item height_auto">
                <div class="short_table_list" key="1">
                    <div class="opt-btn-group">
                        <div><span>证件明细</span></div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th width="45">序号</th>
                            <th>证书名称</th>
                            <th>专业</th>
                            <th>证书编号</th>
                            <th>证书形式</th>
                            <th>证书去向</th>
                            <th>所属公司</th>
                            <th>归还时间</th>
                            <th>归还备注</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody" id="list_list"></tbody>
                    </table>
                    <div class="listerror">提示：<span></span></div>
                </div>
            </div>
        </div>
    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_cert_borrow_gui, data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {


                var list = res.data.list;
                for (var key in list){
                    var str = '';
                    var nums = parseInt(key)+1;
                    str += '<tr>';
                    str += '<td style="width: 45px">'+nums+'</td>';
                    str += '<td><input type="text" listid="'+list[key].id+'" readonly class="layui-input name disabled" value="'+list[key].name+'"></td>';
                    str += '<td><input type="text" readonly class="layui-input major disabled" value="'+list[key].major+'"></td>';
                    str += '<td><input type="text" readonly class="layui-input number disabled" value="'+list[key].number+'"></td>';
                    str += '<td><input type="text" readonly class="layui-input form_name disabled" value="'+list[key].form_name+'"></td>';
                    str += '<td><input type="text" readonly class="layui-input goes_name disabled" value="'+list[key].goes_name+'"></td>';
                    str += '<td><input type="text" readonly class="layui-input chanid_name disabled" value="'+list[key].chanid_name+'"></td>';

                    if(list[key].isedit){
                        str += '<td><input type="text" class="layui-input guidt bdate_ymd" value="'+list[key].guidt+'" readonly></td>';
                        str += '<td><input type="text" class="layui-input guiname" value="'+list[key].guiname+'"></td>';
                    }else{
                        str += '<td><input type="text" class="layui-input guidt disabled" value="'+list[key].guidt+'" readonly></td>';
                        str += '<td><input type="text" class="layui-input guiname disabled" disabled value="'+list[key].guiname+'"></td>';
                    }

                    str += '</tr>';
                    $("#list_list").append(str);
                }

                render_date();
                render_from();
                initParseMoney();
            }
        });


        form.on('submit(add)', function(data){
            parseMoney(data);

            var list = [''];
            try {
                $('#list_list tr').each(function (i) {
                    var id = $(this).find('.name').attr('listid');
                    var guidt = $(this).find('.guidt').val();
                    var guiname = $(this).find('.guiname').val();

                    list.push({
                        id:id,
                        guidt:guidt,
                        guiname:guiname,
                    });
                });
            } catch(e) {
                $(".listerror").find('span').text(e.message);
                $(".listerror").show();
                return false;
            }
            $(".listerror").hide();
            data.field.list = list;


            data.field.id = param_id;

            facade.ajax({url: ask_cert_borrow_gui, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });
            return false;
        });

    });




</script>
</body>
</html>
